/// @tags: NetFlow MinCut
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>

typedef long long ll;

int const N = 1e4 + 5;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

int n, c, p[N], s[N];
ll dp[2][N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("CF724E Goods transportation.in", "r", stdin);
  freopen("CF724E Goods transportation.out", "w", stdout);
#endif
#endif

  read(n), read(c);
  for (int i = 1; i <= n; ++i) read(p[i]);
  for (int i = 1; i <= n; ++i) read(s[i]);
  for (int i = 1; i <= n; ++i) {
    int cur = i & 1, las = cur ^ 1;
    memset(dp[cur], 0x3f, sizeof(dp[cur]));
    dp[cur][0] = dp[las][0] + p[i];
    for (int j = 1; j <= i; ++j)
      dp[cur][j] = std::min(dp[las][j] + p[i] + 1ll * c * j, dp[las][j - 1] + s[i]);
  }
  ll ans = 0x3f3f3f3f3f3f3f3f;
  for (int i = 0; i <= n; ++i) ans = std::min(ans, dp[n & 1][i]);
  printf("%lld", ans);
  return 0;
}